<%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2020/7/3
  Time: 17:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"  isELIgnored="true" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <title>供应商联系人</title>
    <%@include file="/common/com.jsp"%>
</head>
<body>
<div id="root">

    <card>
        <i-Button type="Primary" Icon="ios-refresh" ghost @click="shuaxin">刷新</i-Button>
<shiro:hasPermission name="supplier:add">
        <i-button type="dashed" @click="add">添加</i-button>
</shiro:hasPermission>
    </card>

    <i-table :columns="columns" :data="data" border stripe height="400">
        <template slot-scope="{row,index}" slot="action">
<shiro:hasPermission name="supplier:update">
            <i-Button type="dashed" @click="update(row,index)">修改</i-Button>
</shiro:hasPermission>
<shiro:hasPermission name="supplier:del">
            <i-Button type="dashed" @click="del(row,index)">删除</i-Button>
</shiro:hasPermission>
        </template>
    </i-table>



    <Modal v-model="modaladd"  title="添加供应商联系人" @on-ok="doadd">
        <i-form :label-width="80">
            <Form-Item label="供应商名称">
                <i-input v-model="supper.supperName"></i-input>
            </Form-Item>
            <Form-Item label="姓名">
                <i-input v-model="supper.supperUsername"></i-input>
            </Form-Item>
            <Form-Item label="性别">
                <i-input v-model="supper.supperGender"></i-input>
            </Form-Item>
            <Form-Item label="手机">
                <i-input v-model="supper.supperPhone"></i-input>
            </Form-Item>
            <Form-Item label="职位">
                <i-input v-model="supper.supperPosition"></i-input>
            </Form-Item>
            <Form-Item label="QQ">
                <i-input v-model="supper.supperQq"></i-input>
            </Form-Item>
            <Form-Item label="邮箱">
                <i-input v-model="supper.supperEmail"></i-input>
            </Form-Item>
        </i-form>
    </Modal>

    <Modal v-model="modalupdate"  title="修改联系人" @on-ok="doupdate">
        <i-form :label-width="80">
            <Form-Item label="供应商名称">
                <i-input v-model="supper.supperName"></i-input>
            </Form-Item>
            <Form-Item label="姓名">
                <i-input v-model="supper.supperUsername"></i-input>
            </Form-Item>
            <Form-Item label="性别">
                <i-input v-model="supper.supperGender"></i-input>
            </Form-Item>
            <Form-Item label="手机">
                <i-input v-model="supper.supperPhone"></i-input>
            </Form-Item>
            <Form-Item label="职位">
                <i-input v-model="supper.supperPosition"></i-input>
            </Form-Item>
            <Form-Item label="QQ">
                <i-input v-model="supper.supperQq"></i-input>
            </Form-Item>
            <Form-Item label="邮箱">
                <i-input v-model="supper.supperEmail"></i-input>
            </Form-Item>
        </i-form>
    </Modal>






    <template>
        <Page :total="total"
              show-elevator
              :page-size="pageSize"
              style="margin-left: 340px;margin-top:15px"
              :current.sync="pageNo"
              show-sizer
              prev-text="上一页"
              next-text="下一页"
              :page-size-opts="[5,10,20,30,40]"
              show-total
              @on-page-size-change="pageSize=arguments[0];getsupplierlist();"
              @on-change="getsupplierlist"/>
    </template>
</div>
</body>
<script>
    new  Vue({
        el:"#root",
        data:{
            columns:[
                {title:"供应商名称",key:"supperName"},
                {title:"姓名",key:"supperUsername"},
                {title:"性别",key:"supperGender"},
                {title:"职位",key:"supperPosition"},
                {title:"手机",key:"supperPhone"},
                {title:"QQ",key:"supperQq"},
                {title:"邮箱",key:"supperEmail"},
                {title:"其他操作",slot:"action"}
            ],
            data:[],
            supplierlist:[],
            total:50,
            pageNo:1,
            pageSize:5,
            modaladd:false,
            modalupdate:false,
            modaladdissue:false,
            supper:{},


        },
        mounted(){
            this.getsupplierlist();
        },
        methods:{
            getsupplierlist(){
                axios.get(`${apath}/supper/pagelist/${this.pageSize}/${this.pageNo}`,{params:this.Supper})
                    .then(({data})=>{
                        console.log(data.result);
                        this.data=data.result.record;
                        this.total=data.result.total;
                    })
            },




            del(row,index){
                let _this=this;
                iview.Modal.confirm({
                    title:"是否确定删除?",
                    content:"此操作一旦确定无法返回,请谨慎使用",
                    onOk(){
                        axios.get(`${apath}/supper/supperdel/${row.id}`)
                            .then(({data})=>{
                                iview.Message.success({content: data.msg})
                                _this.getsupplierlist();
                            })
                    }
                })
            },
                    add(){
                        this.supper = {};
                        this.modaladd=true;
                    },
                    doadd(){
                        axios.post(`${apath}/supper/supperadd`,this.supper)
                            .then(({data})=>{
                                alert("添加成功")
                                iview.Message.success({content:data.msg})
                                this.getsupplierlist();
                            })
                    },

            update(row,index){
                this.supper = row;
                this.modalupdate=true;

            },

            doupdate(){
                axios.post(`${apath}/supper/supperupdate`,Qs.parse(params))
                    .then(({data})=>{
                        alert("修改成功")
                        iview.Message.success({content:data.msg})
                        this.getsupplierlist();
                    })
            },
            shuaxin(){
                location.reload();
            },







        }
    })
</script>
</html>
